﻿$(function JQeryTree() {
    $(function LoadCss() {
        var Tree = $("#jquerytree");
        Tree = Tree.children();
        Tree.addClass("Tree");
        Tree = Tree.children();
        while (Tree.is("div")) {
            Tree.addClass("leaf");
            Tree.children().parent().removeClass("leaf");
            Tree.children().parent().addClass("branch");
            Tree = Tree.children();
        }
        var FirstBranchs = $(".Tree").children();
        FirstBranchs.css("display", "block");
        FirstBranchs.css("border", "0");
    });
    $(function LoadEvent() {
        $(".branch").click(function () {
            $(this).children().slideToggle();
            $(this).toggleClass("branch");
            $(this).toggleClass("branchon");
            return false; //阻止冒泡
        });
        $(".leaf").click(function () {
            return false; //阻止冒泡
        });
    });
});